
/**
 * Used to represent a symbol
 * @author Tobin Chee
 *
 */
public class LinkingSymbol {
	/** Label of symbol.
	 */
	private String label;
	/** Address symbol is located.
	 */
	private int address;
	/** Usage of the symbol.
	 */
	private SymbolUsage usage;
	/** Module name containing symbol.
	 */
	private String moduleName;
	
	/** Enumerations of the possible usages of linking symbols.
	 *
	 */
	public enum SymbolUsage{
		/**
		 * Symbol represents a program name.
		 */
		MODULE_NAME,
		/**
		 * Symbol represent an external memory reference.
		 */
		EXTERNAL;
	}
	
	/**
	 * Default constructor
	 */
	public LinkingSymbol(){
		label = "";
		address = 0;
		usage = SymbolUsage.EXTERNAL; //arbitrary default value
		moduleName = "";
	}
	
	/**
	 * Constructor.
	 * 
	 * @param lbl symbol label.
	 * @param addr address in memory of symbol.
	 * @param use how the symbol is used.
	 * @param modName moduleName in which this symbol is defined.
	 */
	public LinkingSymbol(String lbl, int addr, SymbolUsage use, String modName){
		label = lbl;
		address = addr;
		usage = use;
		moduleName = modName;
	}
	
	/**
	 * Updates symbol label value to lbl.
	 * 
	 * @param lbl symbol label.
	 */
	public void updateLabel(String lbl){
		label = lbl;
	}
	
	/**
	 * Returns symbol label.
	 * 
	 * @return symbol label.
	 */
	public String getLabel(){
		return label;
	}
	
	/**
	 * Updates symbol address value to addr.
	 * 
	 * @param addr memory address where symbol is defined.
	 */
	public void updateAddress(int addr){
		address = addr;
	}
	
	/**
	 * Returns symbol address.
	 * 
	 * @return symbol address
	 */
	public int getAddress(){
		return address;
	}
	
	/**
	 * Updates symbol usage value to use.
	 * 
	 * @param use what symbol is used for.
	 */
	public void updateUsage(LinkingSymbol.SymbolUsage use){
		usage = use;
	}
	
	/**
	 * Returns symbol usage.
	 * 
	 * @return symbol usage.
	 */
	public LinkingSymbol.SymbolUsage getUsage(){
		return usage;
	}
	
	/**
	 * Updates symbol module name to modName.
	 * 
	 * @param modName module name.
	 */
	public void updateModuleName(String modName){
		moduleName = modName;
	}
	
	/**
	 * Returns symbol module name.
	 * 
	 * @return symbol module name.
	 */
	public String getModuleName(){
		return moduleName;
	}
}
